<?php

namespace App\Http\Controllers\API;

use App\Http\Controllers\Controller;
use App\Http\Requests\CategoryCreateRequest;
use App\Models\Category;
use App\Utils\HelperUtil;

class CategoryController extends Controller
{
    public function store(CategoryCreateRequest $request)
    {
        Category::create($request->all());

        return HelperUtil::responseSuccess(null);
    }

    public function show(Category $category)
    {
        return HelperUtil::responseSuccess($category);
    }

    public function update(CategoryCreateRequest $request, Category $category)
    {
        $category->update($request->all());

        return HelperUtil::responseSuccess(null);
    }

    public function destroy(Category $category)
    {
        // TODO delete category
    }

    public function all()
    {
        return HelperUtil::responseSuccess(Category::all());
    }
}